package org.example.leetCode;

/**
 * @author Administrator
 */
public class MirrorTree {
    public TreeNode mirrorTree(TreeNode root) {
        if (root == null) {
            return null;
        }
        return dfs(root);

    }

    private TreeNode dfs(TreeNode root) {
        if (root == null) {
            return null;
        }
        root.right = dfs(root.right);
        root.left = dfs(root.left);
        TreeNode treeNode = root.left;
        root.left = root.right;
        root.right = treeNode;
        return root;
    }


    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }
}
